Using the Level of Detail node

Use the Level of Detail node when you want to show different appearances of the same object, or different object, based on the viewing distance of the Level of Detail node. Each child of a Level of Detail node sets a single appearance and a constraint when that appearance is selected and shown. The constraint can be either:

Note that the Level of Detail nodes affect only rendering, which is why you cannot use them in layouts. The size of the Level of Detail node is the size of its largest child, even if that child is not visible at the current Level of Detail node.

Creating a Level of Detail node

To create a Level of Detail node:

  1. In the Project press Alt and right-click the node where you want to create a Level of Detail node and select Level of Detail.
    Note that you create Level of Detail only inside 3D nodes.
  2. In the Properties set the Type property to either:

    For example, set Type to Distance.

  3. In the Project add child nodes to the Level of Detail node.
    For example, add a Sphere, a Box, and a Plane node.
    For each item you add to the Level of Detail node, based on the type of Level of Detail node you selected, Kanzi Studio adds either the Minimum Distance or Minimum Area property.
  4. Select each node you added to the Level of Detail node and in the Properties, depending on the Level of Detail node you selected, set either the Minimum Distance or Minimum Area property value to define when the Level of Detail node shows each item.
    For example, if you set Type to Distance, in the Project select:
    1. Sphere and set its Minimum Distance property to 0.
    2. Box and set its Minimum Distance property to 10.
    3. Plane and set its Minimum Distance property 20.

    When you move the Level of Detail node or the preview camera along the z axis, Kanzi shows the child node whose distance value is the next largest compared to the Level of Detail node’s distance to the preview camera.

Using the Level of Detail node in the API

To create a distance level of detail selector node with three levels of detail:

// Create a level of detail selector node named LOD selector.
LevelOfDetail3DSharedPtr lodSelector = LevelOfDetail3D::create(domain, "LOD selector");

// Add three levels of detail, one child for each level.
lodSelector->addChild(lodHigh);
lodSelector->addChild(lodMedium);
lodSelector->addChild(lodLow);

// Set the level of detail selector node to show its child objects based on the
// level of detail selector node's distance from the preview camera.
lodSelector->setType(LevelOfDetail3D::LodTypeDistance);
// Use low level of distance child (lodLow) when the preview camera distance is
// at least 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodLow, 10.0f);
// Use medium level of distance child (lodMedium) when the preview camera distance
// is at least 5.0f, but less than 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodMedium, 5.0f);
// Use high level of distance child (lodHigh) when preview camera distance is
// less than 5.0f.
LevelOfDetail3D::setMinimumDistance(*lodHigh, 0.0f);

For details, see the LevelOfDetail3D class in the API reference.

Level of Detail property types and messages

For a list of the available property types and messages for the Level of Detail node, see Level of detail.

See also

Using the Empty Node nodes